<?php
header('Content-Type: text/html; charset=utf-8');

require '../config/connexion_db.config.php';


$token = $_POST['token'];

if(isset($_POST['titre']))	$titre=$_POST['titre'];
	else $titre='';
	
if(isset($_POST['nom'])) $nom=$_POST['nom'];
	else $nom='';
	
if(isset($_POST['prenom']))	$prenom=$_POST['prenom'];
	else $prenom='';
	
if(isset($_POST['initiale'])) $initiale=$_POST['initiale'];
	else $initiale='';

if(isset($_POST['genre']))	$genre=$_POST['genre'];
	else $genre='';
	
if(isset($_POST['email']))	$email=$_POST['email'];
	else $email='';

if(isset($_POST['type_ins']))	$type_ins=$_POST['type_ins'];
	else $type_ins='';

if(isset($_POST['institution']))	$institution=$_POST['institution'];
	else $institution='';

if(isset($_POST['type_instit']))	$type_instit=$_POST['type_instit'];
	else $type_instit='';

if(isset($_POST['laboratoire']))	$laboratoire=$_POST['laboratoire'];
	else $laboratoire='';
	
if(isset($_POST['statut']))	$statut=$_POST['statut'];
	else $statut='';
	
if(isset($_POST['adresse']))	$adresse=$_POST['adresse'];
	else $adresse='';

if(isset($_POST['ville'])) $ville=$_POST['ville'];
	else $ville='';
	
if(isset($_POST['zip']))	$zip=$_POST['zip'];
else $zip='';

if(isset($_POST['etat']))	$etat=$_POST['etat'];
	else $etat='';

if(isset($_POST['pays'])) $pays=$_POST['pays'];
	else $pays='';

if(isset($_POST['tel']))	$tel=$_POST['tel'];
	else $tel='';

if(isset($_POST['mobile'])) $mobile=$_POST['mobile'];
	else $mobile='';

if(isset($_POST['nationalite']))	$nationalite=$_POST['nationalite'];
	else $nationalite='';

if(isset($_POST['alimentation'])) $alimentation=$_POST['alimentation'];
	else $alimentation='';

if(isset($_POST['gluten']) || isset($_POST['lactose'])){
$intolerance='';
if(isset($_POST['gluten'])) $intolerance.=$_POST['gluten'].',';
if(isset($_POST['lactose'])) $intolerance.=$_POST['lactose'].',';

		
$intolerance=substr($intolerance,0,-1);
}else $intolerance='';
if(isset($_POST['nb_resume'])){
$nb_resume=$_POST['nb_resume'];
}else $nb_resume='';


	echo $titre.'<br>';

	echo	$nom.'<br>';

	echo 	$prenom.'<br>';

	echo	$initiale.'<br>';

	echo	$genre.'<br>';

	echo	$email.'<br>';

	echo	$type_ins.'<br>';

	echo	$institution.'<br>';

	echo	$type_instit.'<br>';

	echo	$laboratoire.'<br>';

	echo	$statut.'<br>';

	echo	$adresse.'<br>';

	echo	$ville.'<br>';

	echo	$zip.'<br>';

	echo	$etat.'<br>';

	echo	$pays.'<br>';

	echo	$tel.'<br>';

	echo	$mobile.'<br>';

	echo	$nationalite.'<br>';

	echo	$alimentation.'<br>';

	echo	$intolerance.'<br>';

	echo	$nb_resume.'<br>';



try
{

$query='UPDATE 	users 
		SET 	titre = ?, 
				nom = ?,
				prenom = ?,
				initiale = ?,
				genre = ?,
				email = ?, 
				type_ins = ?,
				institution = ?,
				type_instit = ?,
				laboratoire = ?,
				statut = ?,
				adresse = ?,
				ville = ?,
				zip = ?,
				etat = ?,
				pays = ?,
				tel = ?,
				mobile = ?,
				nationalite = ?,
				alimentation = ?,
				intolerance = ?,
				nb_resume = ?
		WHERE 	token = ?';
		
$params = array(	$titre,
					$nom,
					$prenom,
					$initiale,
					$genre,
					$email,
					$type_ins,
					$institution,
					$type_instit,
					$laboratoire,
					$statut,
					$adresse,
					$ville,
					$zip,
					$etat,
					$pays,
					$tel,
					$mobile,
					$nationalite,
					$alimentation,
					$intolerance,
					$nb_resume,
					$token);

mysql_query("SET NAMES 'utf8'");
$request = $connexion->prepare($query);
$request->execute($params);
}
catch(PDOException $e)
{
	echo $e->getMessage();
}


$connexion='';
?>
